<?php
class LogDauData extends AppModel
{
    public $name = 'LogDauData';
    public $primaryKey = '_id';

    public function get_dau($_db_name, $_day)
    {
        $this->useDbConfig = $_db_name['log'];

        $start_date = mktime(0,0,0,8,$_day,2014);
        $end_date = mktime(24,0,0,8,$_day,2014);

        $params = array(
            'conditions' => array(
                'created' => array(
                    '$gte' => New Mongodate($start_date),
                    '$lte' => New Mongodate($end_date)
                )
            )
        );

        $data = $this->find('first', $params);
        //pr($data);
        return $data;
    }

    public function char_del($_db_name, $_usn, $_char_id)
    {
        $this->useDbConfig = $_db_name['log'];

        $params = array('usn' => $_usn);
        if( !$this->deleteall($params) )
            return false;

        return true;
    }

    public function delect_all($_db_name)
    {
        $this->useDbConfig = $_db_name['log'];
        $this->deleteAll(array('_id not' => null));
        return true;
    }

}